<?php
$htmlData = '';
if (!empty($_POST['content1'])) {
    if (get_magic_quotes_gpc()) {
        $htmlData = stripslashes($_POST['content1']);
    } else {
        $htmlData = $_POST['content1'];
    }
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"  charset="utf-8"></script>

    <script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form()
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;

  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');

  //自定义验证规则
  form.verify({
    title: function(value){
      if(value.length<1){
        return '姓名不能为空，';
      }
    }
    ,pass: [/(.+){11,11}$/, '手机号必须是11位']
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });

  //监听指定开关
  form.on('switch(switchTest)', function(data){
    layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
      offset: '6px'
    });
    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
  });

  //监听提交



});



layui.use('layedit', function(){
  var layedit = layui.layedit
  ,$ = layui.jquery;

  //构建一个默认的编辑器
  var index = layedit.build('LAY_demo1');


  $('.site-demo-layedit').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });


});
</script>
    <link rel="stylesheet" href="kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="kindeditor/plugins/code/prettify.css" />
    <script charset="utf-8" src="kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>
    <script charset="utf-8" src="kindeditor/plugins/code/prettify.js"></script>
    <script>
        KindEditor.ready(function(K) {
            var editor1 = K.create('textarea[name="content1"]', {
                cssPath : 'kindeditor/plugins/code/prettify.css',
                uploadJson : 'kindeditor/php/upload_json.php',
                fileManagerJson : 'kindeditor/php/file_manager_json.php',
                allowFileManager : true,
                afterCreate : function() {
                    var self = this;
                    K.ctrl(document, 13, function() {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function() {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                }
            });
            prettyPrint();
        });
    </script>
</head>
<body>
    
        <blockquote class="layui-elem-quote">所有人不必须证实新闻的可靠性,不得弄虚作假</blockquote>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>新闻填写</legend>
</fieldset>
    <form action="xinwentianjia.php" class="layui-form" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">作者</label>
                <div class="layui-input-inline">
                     <input type="text" name="name"  placeholder="请输入姓名" autocomplete="off" class="layui-input"  lay-verify="title">
                 </div>
        <div class="layui-form-mid layui-word-aux">请准确填写姓名</div>
        </div>

        

        <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input type="text" name="phone1" lay-verify="pass"  placeholder="请输入手机号" autocomplete="off" class="layui-input"> 

            </div>

            <label class="layui-form-label">固定电话</label><div class="layui-input-inline">
                <input type="text" name="phone2"  placeholder="请输入固定电话" autocomplete="off" class="layui-input" lay-verify="required"> 
            </div>
        <div class="layui-form-mid layui-word-aux">填写联系电话</div>
         </div>
         <div class="layui-form-item">
            <label class="layui-form-label">新闻标题</label>
                <div class="layui-input-inline">
                     <input type="text" name="title"  placeholder="请输入新闻标题" autocomplete="off" class="layui-input" lay-verify="required">
                 </div>
        <div class="layui-form-mid layui-word-aux"></div>
        </div>      
        </div>
       
        
       

     <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">新闻内容</label>
    <div class="layui-input-block">
<!--      <textarea placeholder="请输入内容" class="layui-textarea" id="LAY_demo1" name="content" style="display: none"></textarea>-->
        <?php echo $htmlData; ?>
<!--        <form name="example" method="post" action="demo.php">-->
            <textarea name="content1" style="width:700px;height:200px;visibility:hidden;"><?php echo htmlspecialchars($htmlData); ?></textarea>
            <br />
<!--            <input type="submit" name="button" value="提交内容" /> (提交快捷键: Ctrl + Enter)-->
<!--        </form>-->
    </div>
  </div>

  
   <div class="layui-form-item">
    <div class="layui-input-block">
    <input type="submit" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit="" lay-filter="demo1"></input> 
      
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      
    </div>
    
    </form>
  
</body>
</html>